package reflect;

import java.lang.reflect.Method;

public class ReflectDemo5 {
    public static void main(String[] args) throws Exception {
        Person p = new Person();
        p.say("你好");

        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();
        Method m = cls.getMethod("say", String.class);
        m.invoke(obj,"大家好！");


        Object obj1 = cls.newInstance();
        Method m1 = cls.getMethod("say", String.class,int.class);
        m1.invoke(obj1,"大家好",5);
    }
}
